<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>爱心书屋管理信息系统</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<!--
	.left{
	margin-left:400px;
	width:220px;
	height:165px;
	float:left;
	background:url("dwz/themes/default/images/loveBook1.jpg");
	position:relative;
	}
	.mid{
	margin-left:0px;
	width:260px;
	height:170px;
	float:left;
	position:relative;
	}
	.top {
	margin-top: 0px;
	float: left;
	width: 100%;
	height: 130px;
	background: url("dwz/themes/default/images/top.gif");
}
.center{
margin-top: 0px;
height: 305px;
float:left;
background: url("dwz/themes/default/images/right_m.gif");
}

.left{
    background: url("dwz/themes/default/images/right_m.gif");
    height: 305px;
    float: left;
    width:300px;
}

.right{
    background: url("dwz/themes/default/images/right_m.gif");
    height: 305px;
    float: right;
    width:300px;
}
.main{
   background: url("dwz/themes/default/images/main.gif");
    height: 305px;
    width:437px;
    float: left;
    background-repeat: no-repeat;
}


.main .form{
margin-top: 83px;
margin-left: 115px;
}
	-->
<style type="text/css">
.top {
	width: expression(body.clientWidth);
	height: 130px;
	left: 0px;
	top: 0px;
	position: absolute;
	background: url("dwz/themes/default/images/top.gif");
}

.main {
	background: url("dwz/themes/default/images/main.gif");
	height: 305px;
	width: 437px;
	position: absolute;
	left: expression(( body.clientWidth-437)/2);
	top: 130px;
	background-repeat: no-repeat;
}

.left {
	background: url("dwz/themes/default/images/right_m.gif");
	left: 0px;
	top: 129px;
	height: 305px;
	width: expression(( body.clientWidth-437)/2);
	position: absolute;
}

.right {
	background: url("dwz/themes/default/images/right_m.gif");
	right: 0px;
	top: 129px;
	height: 305px;
	width: expression(( body.clientWidth-437)/2 +2);
	position: absolute;
}

.form {
	position: absolute;
	top: 84px;
	left: 115px;
}

#login {
	background: url("dwz/themes/default/images/login.gif");
	width: 75px;
	height: 25px;
	border: 0px;
	cursor: pointer;
}

#register {
	background: url("dwz/themes/default/images/register.gif");
	width: 75px;
	height: 25px;
	border: 0px;
	cursor: pointer;
}
</style>
<style>
</style>
<script type="text/javascript" src="dwz/js/jquery-1.7.2.js">
</script>
<script type="text/javascript">
$(function($) {
    $("#register").click( function () { 
			window.location.href="register.jsp";
	});
	$("#login").click(function() {
		var url = 'login_UserInfo_ajax';
		params = {
			userId : $('#userName').attr('value'),
			userPassword : $('#userPassword').attr('value')
		}
		//window.alert("userName" + params.userId + " " + url );
		$.post(url, params, callbackFunction, 'json');
		function callbackFunction(data) {
			if (data.back == "读者") {
 				window.location.href = "reader"; 
			} else if (data.back == "图书管理员") {
				window.location.href = "administrator";
			} else if (data.back == "系统管理员") {
				//window.alert("administrator");
				window.location.href = "administrator";
			} else {
				alert(data.back);
			}
		}
	});
	$('#userName').keydown(function(e){
         if(e.keyCode==13){
           var url = 'login_UserInfo_ajax';
		   params = {
			 userId : $('#userName').attr('value'),
			 userPassword : $('#userPassword').attr('value')
		   }
		  $.post(url, params, callbackFunction, 'json');
		  function callbackFunction(data) {
			  if (data.back == "读者") {
				 window.location.href = "reader";
			  } else if (data.back == "图书管理员") {
				 window.location.href = "administrator";
			  } else if (data.back == "系统管理员") {
				 window.location.href = "administrator";
			  } else {
				 alert(data.back);
			 }
		 }
		}
   });
	$('#userPassword').keydown(function(e){
         if(e.keyCode==13){
           var url = 'login_UserInfo_ajax';
		   params = {
			 userId : $('#userName').attr('value'),
			 userPassword : $('#userPassword').attr('value')
		   }
		  $.post(url, params, callbackFunction, 'json');
		  function callbackFunction(data) {
			  if (data.back == "读者") {
				 window.location.href = "reader";
			  } else if (data.back == "图书管理员") {
				 window.location.href = "administrator";
			  } else if (data.back == "系统管理员") {
				 window.location.href = "administrator";
			  } else {
				 alert(data.back);
			 }
		 }
		}
   });
});

</script>
</head>

<body>
	<div class="top"></div>
	<div class="center">
		<div class="left"></div>
		<div class="main">
			<div class="form">
				<table>
					<tr class="userId">
						<td colspan="2"><input type="text" name="userId"
							id="userName" size="24" /></td>
					</tr>
					<tr class="password">
						<td height="38" colspan="2"><input type="password"
							name="userPassword" id="userPassword" size="26" /></td>
					</tr>
					<tr>
						<td height="38"><input type="button" align="right" id="login"
							size="26" /></td>
						<td height="38"><input type="button" align="left"
							id="register" size="26" /></td>
					</tr>
				</table>
			</div>
		</div>
		<div class="right"></div>
	</div>


</body>
</html>
